﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace AcmeSportsStore
{
    public partial class TestForm : Form
    {
        SportsStore mStore = new SportsStore();

        LayoutController mFormLayoutCtrl;
        
        public TestForm()
        {
            InitializeComponent();
        }

        void GenerateSportsStoreData()
        {
            mStore.Clear();
            FileReader fr = new FileReader();
            mStore = fr.ReadSportsItems();
/*
            mStore.AddItem(new SportsItem("M0001",
                "Basket ball",
                "Spalding TF1000 Indoor Composite Leather, size 6 ball",
                9999));
            mStore.AddItem(new SportsItem("M0002",
                "Net ball",
                "Gilber International Netball Grade 1 rubber surface, size 5 ball",
                7995));
            mStore.AddItem(new SportsItem("M0003",
                "Soccer ball",
                "Nike T90 Ascente Hi-Vis EPL Match Soccer Ball, size 5 ball",
                15999));
            mStore.AddItem(new SportsItem("M0004",
                "Boxing gloves",
                "Everlast Men's Bronx Training Gloves - Red",
                10999));
            mStore.AddItem(new SportsItem("M0005",
                "Boxing mitts",
                "Everlast Champs with Pre curved shape and Separated fingers",
                7499));
            mStore.AddItem(new SportsItem("M0006",
                "Cycling helmet",
                "Adura Ascent Cycling Helmet Xsmall/Small - Blue",
                6995));
            mStore.AddItem(new SportsItem("M0007",
                "Chess Board",
                "A fun game for the whole family",
                2550));
 * */
        }

        private void btnOrderById_Click(object sender, EventArgs e)
        {
            int count = mStore.Count;

            lstMain.Items.Clear();
            for (int i = 0; i < count; i++)
            {
                SportsItem item = mStore.GetItemByIndexForId(i);
                lstMain.Items.Add(item.ToString());
            }
        }

        private void TestForm_Load(object sender, EventArgs e)
        {
            GenerateSportsStoreData();

            mFormLayoutCtrl = new LayoutController(this);
        }

        private void btnOrderByName_Click(object sender, EventArgs e)
        {
            int count = mStore.Count;

            lstMain.Items.Clear();
            for (int i = 0; i < count; i++)
            {
                SportsItem item = mStore.GetItemByIndexForName(i);
                lstMain.Items.Add(item.ToString());
            }
        }

        private void btnOrderByPrice_Click(object sender, EventArgs e)
        {
            int count = mStore.Count;

            lstMain.Items.Clear();
            for (int i = 0; i < count; i++)
            {
                SportsItem item = mStore.GetItemByIndexForPrice(i);
                lstMain.Items.Add(item.ToString());
            }
        }

        private void btnOrderByDesc_Click(object sender, EventArgs e)
        {
            int count = mStore.Count;

            lstMain.Items.Clear();
            for (int i = 0; i < count; i++)
            {
                SportsItem item = mStore.GetItemByIndexForDescription(i);
                lstMain.Items.Add(item.ToString());
            }
        }

        private void TestForm_Resize(object sender, EventArgs e)
        {
            mFormLayoutCtrl.UpdateAfterResizing();
        }

        private void TestForm_Layout(object sender, LayoutEventArgs e)
        {
        }
    }
}
